<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Repositories\BannerRepo;
use App\Repositories\CategoryRepo;
use App\Repositories\ProductRepo;
use App\Repositories\NewsRepo;
use App\Repositories\AreaRepo;
class IndexController extends ApiBaseController
{
	//用户打开应用使用此方法
	public function index()
	{
		$data = [];
		//获取轮播图
		$bannerRepo = new BannerRepo();
		$data['banner'] = $bannerRepo->getBannerList(['status'=>1],3);
		//推荐产品
		$productRepo = new ProductRepo();
		$data['recommend'] = $productRepo->getRecommend();
		//产品列表
		$data['products']    = $productRepo->getProductList(['is_able'=>1],20);
		//排行榜
		$data['sort_lists'] = $productRepo->getSortList(5);
		//专区
		$areaRepo = new AreaRepo();
		$data['scopes'] = $areaRepo->getAreaProductList();
		//新闻
		$newsRepo = new NewsRepo();
		$data['news']  = $newsRepo->getHomeNews();
		return $this->sucRes(200,$data);
	}

}
